//使用队列的思想 本质上还是栈
let test = [1,2,,null,[3,4,[5,6,[7,8]]]]
Array.prototype.myFlat = function(deep){
    let queue = [...this]
    let res = []
    while(queue.length){
        let item = queue.shift()
        if(Array.isArray(item)){
            queue.unshift(...item)
        }else{
           res.push(item)
        }
        
    }
    return res
}
console.log(test.myFlat(3));